package com.realtyManage.springboot.Utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * code获取类
 */
public class CodeUtils {
    public static String getCode() {
        String code = "";
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
        String time = sdf.format(new Date());
        for (int i = 0; i < 8; i++) {
            // 得到随机字母
            char c = (char) ((Math.random() * 26) + 97);
            // 拼接成字符串
            code += (c + "");
        }
        code = code+time;
        for (int i = 0; i < 4; i++) {
            // 得到随机字母
            char c = (char) ((Math.random() * 26) + 97);
            // 拼接成字符串
            code += (c + "");
        }
        return code;
    }
}
